package com.xuecheng.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xuecheng.api.system.model.dto.CourseCategoryDTO;
import com.xuecheng.system.convert.CourseCategoryConvert;
import com.xuecheng.system.entity.CourseCategory;
import com.xuecheng.system.entity.ext.CourseCategoryNode;
import com.xuecheng.system.mapper.CourseCategoryMapper;
import com.xuecheng.system.service.CourseCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 课程分类 服务实现类
 * </p>
 *
 * @author itcast*/


@Slf4j
@Service
public class CourseCategoryServiceImpl extends ServiceImpl<CourseCategoryMapper, CourseCategory> implements CourseCategoryService {



    public List<CourseCategoryDTO> queryTreeNodes() {

        //调用mp api获得mapper数据
        CourseCategoryMapper baseMapper = this.getBaseMapper();
        //调用自定义方法
        List<CourseCategoryNode> courseCategoryNodes = baseMapper.selectTreeNodes();
        //将数据转化成dto并返回
        List<CourseCategoryDTO> dtos = CourseCategoryConvert.INSTANCE.nodes2dtos(courseCategoryNodes);

        return dtos;
    }
}
